import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";

export type PageResult = {
  success: boolean;
  data: {
    /** 列表数据 */
    list: Array<any>;
    /** 总数 */
    total?: number;
  };
  errMsg: "";
};

export type DataResult = {
  success: boolean;
  data?: {};
  errMsg: "";
};

export type UploadResult = {
  errno: number;
  data?: {
    url?: string;
    alt?: string;
    href?: string;
    poster?: string;
  };
  message?: string;
};

export const queryNoticeList = (data?: object) => {
  return http.request<PageResult>("post", baseUrlApi("queryNoticeList"), {
    data
  });
};

export const updateNoticeStatus = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("updateNoticeStatus"), {
    data
  });
};

export const addOrUpdateNotice = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("addOrUpdateNotice"), {
    data
  });
};

export const deleteNotice = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("deleteNotice"), {
    data
  });
};

export const querySysUserListByBm = () => {
  return http.request<PageResult>("get", baseUrlApi("querySysUserListByBm"));
};
